<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
var re = /abc/gi;
var s = "abc\nabc";
var res;
while(res = re.exec(s)){
    console.log(res[0]);
}
</script>
</body>
</html>